//
//  WZMenuViewController.m
//  ETong
//
//  Created by wanzhao on 15/12/17.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZMenuViewController.h"
#import "WZRootMenuCell.h"
#import "WZSuggestController.h"

@interface WZMenuViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, weak) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *menuArray;

@end
@implementation WZMenuViewController


#pragma mark 懒加载
- (NSMutableArray *)menuArray
{
    if (_menuArray == nil) {
        _menuArray = [[NSMutableArray alloc] init];
    }
    return _menuArray;
}
- (void)dealloc
{
    NSLog(@"WZMenuViewController  dealloc");
}

 - (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = RGBCOLORWITH16COLOR(0x2f93e7);
    UITableView *tb = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tb.backgroundColor = ClearColor;
    tb.separatorStyle = UITableViewCellSeparatorStyleNone;
    tb.showsVerticalScrollIndicator = NO;
    tb.scrollEnabled = YES;
    tb.dataSource = self;
    tb.delegate = self;
    [self.view addSubview:tb];
    
    self.tableView = tb;
    
    
    [self setUpData];
}

- (void)setUpData
{
    WZRootMenuItem *item = [[WZRootMenuItem alloc] init];
    item.icon = @"yijianfankui";
    item.title = @"意见反馈";
    item.destVc = [WZSuggestController class];
    [self.menuArray addObject:item];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tableView.frame = self.view.bounds;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.menuArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WZRootMenuItem *item = self.menuArray[indexPath.row];
    WZRootMenuCell *cell = [WZRootMenuCell rootMenuCellWithTableView:tableView];
    cell.item = item;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    WZRootMenuItem *item = self.menuArray[indexPath.row];
    if (item.destVc) {
        if ([self.menuControllerDelegate respondsToSelector:@selector(menuViewControllerDidSelectedWithClass:)]) {
            [self.menuControllerDelegate menuViewControllerDidSelectedWithClass:item.destVc];
        }
    }
}
@end
